package com.mycompany.mywebapp.shared;

import java.util.ArrayList;
import java.util.List;

public class AllObjects {

	protected List<Status> switches = new ArrayList<Status>();
	protected List<Sensor> sensors = new ArrayList<Sensor>();
	protected List<Status> detectors = new ArrayList<Status>();
	protected List<Variator> variators = new ArrayList<Variator>();

	public AllObjects(final List<Status> switches, final List<Sensor> sensors, final List<Status> detectors,final List<Variator> variators){
		this.switches=switches;
		this.sensors=sensors;
		this.detectors=detectors;
		this.variators=variators;
	}

	public void SettingType(){
		int i ;
		for (i=0;i<this.getSwitches().size();i++){
			this.getSwitches().get(i).SettingType();
		}
		for (i=0;i<this.getSensors().size();i++){
			this.getSensors().get(i).SettingType();
		}
		for (i=0;i<this.getDetectors().size();i++){
			this.getDetectors().get(i).SettingType();
		}
		for (i=0;i<this.getVariators().size();i++){
			this.getVariators().get(i).SettingType();
		}
	}
	public AllObjects GetNeeded(String location, String type){
		List<Status> switches = new ArrayList<Status>();
		List<Sensor> sensors = new ArrayList<Sensor>();
		List<Status> detectors = new ArrayList<Status>();
		List<Variator> variators = new ArrayList<Variator>();

		int i = 0;


		for(i=0; i < this.switches.size(); i++){

			if(this.switches.get(i).getLocation().equals(location)){
				if(this.switches.get(i).getType().equals(type)){	
					switches.add(this.switches.get(i));
				}
			}
		}

		for(i=0; i < this.sensors.size(); i++){

			if(this.sensors.get(i).getLocation().equals(location)){
				if(this.sensors.get(i).getType().equals(type)){	
					sensors.add(this.sensors.get(i));
				}
			}
		}
		
		for(i=0; i < this.detectors.size(); i++){

			if(this.detectors.get(i).getLocation().equals(location)){
				if(this.detectors.get(i).getType().equals(type)){	
					detectors.add(this.detectors.get(i));
				}
			}
		}
		
		for(i=0; i < this.variators.size(); i++){

			if(this.variators.get(i).getLocation().equals(location)){
				if(this.variators.get(i).getType().equals(type)){	
					variators.add(this.variators.get(i));
				}
			}
		}

		AllObjects objectsneeded = new AllObjects(switches,sensors,detectors,variators);
		return objectsneeded;
	}



	public List<Status> getSwitches() {
		return switches;
	}

	public void setSwitches(List<Status> switches) {
		this.switches = switches;
	}

	public List<Sensor> getSensors() {
		return sensors;
	}

	public void setSensors(List<Sensor> sensors) {
		this.sensors = sensors;
	}

	public List<Status> getDetectors() {
		return detectors;
	}

	public void setDetectors(List<Status> detectors) {
		this.detectors = detectors;
	}

	public List<Variator> getVariators() {
		return variators;
	}

	public void setVariators(List<Variator> variators) {
		this.variators = variators;
	}
}

